{% extends "./inc/base.html" %} {% block content %}

<section class="vbox">
    <header class="header bg-light dk">
        <ul class="nav nav-tabs pull-left">
            <li class=""><a href="/admin/type/index"><i class="fa fa-file-text text-muted"></i> 分类管理 </a></li>
            {#
            <li class=""><a href="/admin/type/topic"><i class="fa fa-file-text text-muted"></i> 内容管理</a> </li>
#}
            <li class="dropdown active">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cog text-muted"></i> {{clas.title}} <b class="caret"></b></a>
                <ul class="dropdown-menu text-left">
                    {% for val in typeoption %}
                    <li><a href="/admin/type/typeoption/?classid={{val.optionid}}" style="padding-top: 5px;padding-bottom: 5px">{{val.title}}</a></li>
                    {%endfor%}
                </ul>
            </li>


        </ul>
    </header>
    <section class="scrollable wrapper">
        <section class="panel panel-default">


            <form method="post" class="form-horizontal" autocomplete="off" action="/admin/type/update" id="threadtypeform" enctype="multipart/form-data" >
                <header class="panel-heading">
                    分类选项基本设置
                </header>

                <div class=" wrapper">

                        <div class="form-group">
                            <label class="col-sm-2 control-label">名称</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="title" type="text" class="form-control parsley-validated" value="{{info.title}}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">变量名</label>
                        <div class="col-sm-10">
                            <div class="row">
                                <div class="col-md-4"><input name="identifier" type="text" class="form-control parsley-validated" value="{{info.identifier}}" data-required="true"></div>
                                <div class="col-md-12 hidden">
                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">类型</label>
                        <div class="col-sm-10">
                            <div class="row">
                                <div class="col-md-4"><select class="form-control" name="type" onchange="var styles, key;styles=new Array('number','text','radio', 'checkbox', 'textarea', 'select', 'image', 'calendar', 'range', 'info'); for(key in styles) {var obj=document.getElementById('style_'+styles[key]); if(obj) { obj.style.display=styles[key]==this.options[this.selectedIndex].value?'':'none';}}">
                                    <option value="number" {%if info.type == 'number'%}selected=""{%endif%}>数字(number)</option>
                                    <option value="text" {%if info.type == 'text'%}selected=""{%endif%} >字串(text)</option>
                                    <option value="radio" {%if info.type == 'radio'%}selected=""{%endif%} >单选(radio)</option>
                                    <option value="checkbox" {%if info.type == 'checkbox'%}selected=""{%endif%} >多选(checkbox)</option>
                                    <option value="textarea" {%if info.type == 'textarea'%}selected=""{%endif%}>文本(textarea)</option>
                                    <option value="select" {%if info.type == 'select'%}selected=""{%endif%}>选择(select)</option>
                                    <option value="calendar" {%if info.type == 'calendar'%}selected=""{%endif%}>日历(calendar)</option>
                                    <option value="email" {%if info.type == 'email'%}selected=""{%endif%}>电子邮件(email)</option>
                                    <option value="url" {%if info.type == 'url'%}selected=""{%endif%}>超级链接(url)</option>
                                    <option value="image" {%if info.type == 'image'%}selected=""{%endif%}>上传图片(image)</option>
                                    <option value="range" {%if info.type == 'range'%}selected=""{%endif%}>范围(range)</option>
                                </select></div>
                                <div class="col-md-12 hidden">
                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">简短描述(可选)</label>
                        <div class="col-sm-10">
                            <div class="row">
                                <div class="col-md-4"><textarea name="description" class="form-control">{{info.description}}</textarea></div>
                                <div class="col-md-12 hidden">
                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">单位</label>
                        <div class="col-sm-10">
                            <div class="row">
                                <div class="col-md-4"><input name="unit" type="text" class="form-control parsley-validated" value="{{info.unit}}" data-required="true"></div>
                                <div class="col-md-12 hidden">
                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否限制有效期</label>
                        <div class="col-sm-10">
                            <div class="row">
                                <div class="col-md-10">
                                    <label class="radio-inline i-checks">
                                        <input type="radio" value="0" name="expiration"><i></i> 是
                                    </label>
                                    <label class="radio-inline i-checks">
                                        <input type="radio" value="1" name="expiration" checked="checked"><i></i> 否
                                    </label>
                                </div>
                                <div class="col-md-12">
                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 选择是则超过有效期信息自动隐藏.</span>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div {%if info.type != 'number'%}style="display: none;"{%endif%} id="style_number">
                    <header class="panel-heading">
                        数字(number)
                    </header>
                    <div class="wrapper">
                        {%if info.type == "number"%}
                        {%set rules = info.rules|strToJson%}
                        {%endif%}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">数值最大值(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[number][maxnum]" type="text" class="form-control parsley-validated" value="{%if info.type == 'number'%}{{rules.maxnum}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">数值最小值(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[number][minnum]" type="text" class="form-control parsley-validated" value="{%if info.type == 'number'%}{{rules.minnum}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">表单显示长度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[number][inputsize]" type="text" class="form-control parsley-validated" value="{%if info.type == 'number'%}{{rules.inputsize}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">默认值(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[number][defaultvalue]" type="text" class="form-control parsley-validated" value="{%if info.type == 'number'%}{{rules.defaultvalue}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div {%if info.type != 'text'%}style="display: none;"{%endif%} id="style_text">
                    <header class="panel-heading">
                        字串(text)
                    </header>
                    <div class="wrapper">
                        {%if info.type == "text"%}
                        {%set rules = info.rules|strToJson%}
                        {%endif%}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">内容最大长度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[text][maxlength]" type="text" class="form-control parsley-validated" value="{%if info.type == 'text'%}{{rules.maxlength}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">表单显示长度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[text][inputsize]" type="text" class="form-control parsley-validated" value="{%if info.type == 'text'%}{{rules.inputsize}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">关联用户栏目初始值</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><select id="rules[text][profile]" name="rules[text][profile]" class="form-control" >
                                        <option value=""></option>
                                        <option value="constellation" {%if info.type == 'text' and rules.profile == 'constellation'%}selected{%endif%}>星座</option>
                                        <option value="zodiac" {%if info.type == 'text' and rules.profile == 'zodiac'%}selected{%endif%}>生肖</option>
                                        <option value="telephone" {%if info.type == 'text' and rules.profile == 'telephone'%}selected{%endif%}>固定电话</option>
                                        <option value="mobile" {%if info.type == 'text' and rules.profile == 'mobile'%}selected{%endif%}>手机</option>
                                        <option value="idcard" {%if info.type == 'text' and rules.profile == 'idcard'%}selected{%endif%}>证件号</option>
                                        <option value="address" {%if info.type == 'text' and rules.profile == 'address'%}selected{%endif%}>邮寄地址</option>
                                        <option value="zipcode" {%if info.type == 'text' and rules.profile == 'zipcode'%}selected{%endif%}>邮编</option>
                                        <option value="graduateschool" {%if info.type == 'text' and rules.profile == 'graduateschool'%}selected{%endif%}>毕业学校</option>
                                        <option value="company" {%if info.type == 'text' and rules.profile == 'company'%}selected{%endif%}>公司</option>
                                        <option value="occupation" {%if info.type == 'text' and rules.profile == 'occupation'%}selected{%endif%}>职业</option>
                                        <option value="position" {%if info.type == 'text' and rules.profile == 'position'%}selected{%endif%}>职位</option>
                                        <option value="revenue" {%if info.type == 'text' and rules.profile == 'revenue'%}selected{%endif%}>年收入</option>
                                        <option value="affectivestatus" {%if info.type == 'text' and rules.profile == 'affectivestatus'%}selected{%endif%}>情感状态</option>
                                        <option value="lookingfor" {%if info.type == 'text' and rules.profile == 'lookingfor'%}selected{%endif%}>交友目的</option>
                                        <option value="alipay" {%if info.type == 'text' and rules.profile == 'alipay'%}selected{%endif%}>支付宝</option>
                                        <option value="qq" {%if info.type == 'text' and rules.profile == 'qq'%}selected{%endif%}>QQ</option>
                                        <option value="msn" {%if info.type == 'text' and rules.profile == 'msn'%}selected{%endif%}>MSN</option>
                                        <option value="taobao" {%if info.type == 'text' and rules.profile == 'taobao'%}selected{%endif%}>阿里旺旺</option>
                                        <option value="site" {%if info.type == 'text' and rules.profile == 'site'%}selected{%endif%}>个人主页</option>
                                    </select></div>
                                    <div class="col-md-12 ">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 可以指定某个用户栏目作为初始值，方便用户在发帖时填写。
此项优先于默认值.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">默认值(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[text][defaultvalue]" type="text" class="form-control parsley-validated" value="{%if info.type == 'text'%}{{rules.defaultvalue}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div {%if info.type != 'radio'%}style="display: none;"{%endif%} id="style_radio">
                    <header class="panel-heading">
                        单选(radio)
                    </header>
                    <div class="wrapper">
                        {%if info.type == "radio"%}
                        {%set rules = info.rules|strToJson%}
                        {%endif%}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">字段内容</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><textarea name="rules[radio][choices]" class="form-control">{%if info.type == 'radio'%}{{rules.choices}}{%endif%}</textarea></div>
                                    <div class="col-md-12 ">
                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i>
                                        只在项目为可选时有效，每行一个字段，等号前面为字段索引(建议用数字)，后面为内容，例如: <br>
<pre>1:光电鼠标
2:机械鼠标
3:没有鼠标</pre>
注意: 字段确定后请勿修改索引和内容的对应关系，但仍可以新增字段。如需调换显示顺序，可以通过移动整行的上下位置来实现
</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
<div {%if info.type != 'checkbox'%}style="display: none;"{%endif%} id="style_checkbox">
                <header class="panel-heading">
                    多选(checkbox)
                </header>
                <div class="wrapper">
                    {%if info.type == "checkbox"%}
                    {%set rules = info.rules|strToJson%}
                    {%endif%}
                    <div class="form-group">
                        <label class="col-sm-2 control-label">字段内容</label>
                        <div class="col-sm-10">
                            <div class="row">
                                <div class="col-md-4"><textarea name="rules[checkbox][choices]" class="form-control">{%if info.type == 'checkbox'%}{{rules.choices}}{%endif%}</textarea></div>
                                <div class="col-md-12 ">
                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i>
                                        只在项目为可选时有效，每行一个字段，等号前面为字段索引(建议用数字)，后面为内容，例如: <br>
<pre>1:光电鼠标
2:机械鼠标
3:没有鼠标</pre>
注意: 字段确定后请勿修改索引和内容的对应关系，但仍可以新增字段。如需调换显示顺序，可以通过移动整行的上下位置来实现
</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

</div>
                <div {%if info.type != 'textarea'%}style="display: none;"{%endif%} id="style_textarea">
                    <header class="panel-heading">
                        文本(textarea)
                    </header>
                    <div class="wrapper">
                        {%if info.type == "textarea"%}
                        {%set rules = info.rules|strToJson%}
                        {%endif%}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">内容最大长度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[textarea][maxlength]" type="text" class="form-control parsley-validated" value="{%if info.type == 'textarea'%}{{rules.maxlength}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">输入框宽度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[textarea][colsize]" type="text" class="form-control parsley-validated" value="{%if info.type == 'textarea'%}{{rules.colsize}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 ">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 此宽度设置仅在自定义"分类信息发布内容显示模板"时生效.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">输入框行数(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[textarea][rowsize]" type="text" class="form-control parsley-validated" value="{%if info.type == 'textarea'%}{{rules.rowsize}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">默认值(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[textarea][defaultvalue]" type="text" class="form-control parsley-validated" value="{%if info.type == 'textarea'%}{{rules.defaultvalue}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div {%if info.type != 'select'%}style="display: none;"{%endif%} id="style_select">
                    <header class="panel-heading">
                        选择(select)
                    </header>
                    <div class="wrapper">
                        {%if info.type == "select"%}
                        {%set rules = info.rules|strToJson%}
                        {%endif%}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">字段内容</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><textarea name="rules[select][choices]" class="form-control">{%if info.type == 'select'%}{{rules.choices}}{%endif%}</textarea></div>
                                    <div class="col-md-12 ">
                                    <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i>
                                        只在项目为可选时有效，每行一个字段，等号前面为字段索引(建议用数字)，后面为内容，例如:
<pre>1:光电鼠标
2:机械鼠标
3:没有鼠标
1.1:黑色光电鼠标
1.2:红色光电鼠标
1.2.1:蓝牙红色光电鼠标</pre>
注意:<br>
1、 <code>"1.2.1:蓝牙红色光电鼠标"</code>必须有<code>"1.2 = 红色光电鼠标"</code>和<code>"1 = 光电鼠标"</code>这两项<br>
2、 <code>"1.2.1"</code>之间不能有空格<br>
3、 字段确定后请勿修改索引和内容的对应关系，但仍可以新增字段。如需调换显示顺序，可以通过移动整行的上下位置来实现<br>
</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">表单显示长度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[select][inputsize]" type="text" class="form-control parsley-validated" value="{%if info.type == 'select'%}{{rules.inputsize}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>

                <div {%if info.type != 'calendar'%}style="display: none;"{%endif%} id="style_calendar">
                    <header class="panel-heading">
                        日历(calendar)
                    </header>
                    <div class="wrapper">
                        {%if info.type == "calendar"%}
                        {%set rules = info.rules|strToJson%}
                        {%endif%}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">表单显示长度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[calendar][inputsize]" type="text" class="form-control parsley-validated" value="{%if info.type == 'calendar'%}{{rules.inputsize}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div {%if info.type != 'image'%}style="display: none;"{%endif%} id="style_image">
                    <header class="panel-heading">
                        上传图片(image)
                    </header>
                    <div class="wrapper">
                        {%if info.type == "image"%}
                        {%set rules = info.rules|strToJson%}
                        {%endif%}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">图片最大宽度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[image][maxwidth]" type="text" class="form-control parsley-validated" value="{%if info.type == 'image'%}{{rules.maxwidth}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">图片最大高度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[image][maxheight]" type="text" class="form-control parsley-validated" value="{%if info.type == 'image'%}{{rules.maxheight}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 此宽度设置仅在自定义"分类信息发布内容显示模板"时生效.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">表单显示长度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[image][inputsize]" type="text" class="form-control parsley-validated" value="{%if info.type == 'image'%}{{rules.inputsize}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>

                <div {%if info.type != 'range'%}style="display: none;"{%endif%} id="style_range">
                    <header class="panel-heading">
                        范围(range)
                    </header>
                    <div class="wrapper">
                        {%if info.type == "range"%}
                        {%set rules = info.rules|strToJson%}
                        {%endif%}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">数值最大值(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[range][maxnum]" type="text" class="form-control parsley-validated" value="{%if info.type == 'range'%}{{rules.maxnum}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">数值最小值(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[range][minnum]" type="text" class="form-control parsley-validated" value="{%if info.type == 'range'%}{{rules.minnum}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 此宽度设置仅在自定义"分类信息发布内容显示模板"时生效.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">表单显示长度(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[range][inputsize]" type="text" class="form-control parsley-validated" value="{%if info.type == 'range'%}{{rules.inputsize}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 hidden">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 名称不能为空.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">搜索范围预置值(可选)</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-md-4"><input name="rules[range][searchtxt]" type="text" class="form-control parsley-validated" value="{%if info.type == 'range'%}{{rules.searchtxt}}{%endif%}" data-required="true"></div>
                                    <div class="col-md-12 ">
                                        <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i> 设置项目的快速搜索预置数值，逗号分隔，例如：“0,50,100”，将显示 0 - 50、50 - 100 的搜索快捷链接.</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <footer class="panel-footer ">
                    <input type="hidden" name="sortid" value="{{info.typeid}}">
                    <div class="row"><div class="col-sm-offset-2"> <button class="btn btn-primary btn-s-md posttype" type="submit" >确定</button></div></div>

                </footer>
            </form>
        </section>
    </section>
</section>

{% endblock %}
{% block script %}
<script>
    $(function () {
        $(".addtr").click(function () {
            var tr = '<tr>'+
                    '<td></td>'+
                    '<td> <input type="text" class="form-control form-control-text" name="displayorder" value="" ></td>'+
                    '<td><input type="text" class="form-control form-control-text" name="name" value=""></td>'+
                    '<td><input type="text" class="form-control form-control-text" name="description" value=""></td>'+
                    '<td></td>'+
                    '<td></td>'+
                    '</tr>';
            $("#export-form>tbody").append(tr);
        })
        $(".checkdom").click(function () {
            var val = $(this).val();
            var name = $(this).attr('data-name');
            var type = $(this).attr('data-type');
            if($(this).attr("checked")){
                $(this).removeAttr("checked");
                var id = 'tr[data-id="'+val+'"]';
                $(id).remove();
            }else {
                $(this).attr("checked",'true');
                var tr = '  <tr data-id="'+val+'">'+
                        '<input type="hidden" name="optionid" value="'+val+'">'+
                '<td> <input type="text" class="form-control form-control-text" name="displayorder" value="0" ></td>'+
                        '<td><label class="checkbox m-n i-checks"><input type="checkbox" name="available" value="1" checked="checked"><i></i></label></td>'+
                '<td>'+name+'</td>'+
                '<td>'+type+'</td>'+
                '<td><label class="checkbox m-n i-checks"><input type="checkbox" name="required" value="1" ><i></i></label></td>'+
                '<td><label class="checkbox m-n i-checks"><input type="checkbox" name="unchangeable" value="1" ><i></i></label></td>'+
                '<td><label class="checkbox m-n i-checks"><input type="checkbox" name="search_form" value="1"><i></i></label></td>'+
                '<td><label class="checkbox m-n i-checks"><input type="checkbox" name="search_font" value="2" ><i></i></label></td>'+
                '<td><label class="checkbox m-n i-checks"><input type="checkbox" name="subjectshow" value="1" ><i></i></label></td>'+
                '<td><a href="/admin/type/typeview/typeid/{{val.typeid}}" class="text-info"> 编辑</a></td></tr>';
                $('#type-list>tbody').append(tr);
            }
        })
//提交数据
        $(".posttype").click(function () {
            var rules = {};
            var data = {};
            data.optionid = '{{info.optionid}}';
           data.title = $('input[name="title"]').val()||'';
            data.identifier = $('input[name="identifier"]').val()||'';
            data.type = $('select[name="type"]').val();
            data.description = $('input[name="description"]').val()||'';
            data.unit = $('input[name="unit"]').val()||'';
            if(data.type=="number"){
                rules.maxnum = $('input[name="rules[number][maxnum]"]').val()||'';
                rules.minnum = $('input[name="rules[number][minnum]"]').val()||'';
                rules.inputsize = $('input[name="rules[number][inputsize]"]').val()||'';
                rules.defaultvalue = $('input[name = "rules[number][defaultvalue]"]').val()||'';
                data.rules = JSON.stringify(rules);
            }else if(data.type == "text"){
                rules.maxlength = $('input[name="rules[text][maxlength]"]').val()||'';
                rules.inputsize = $('input[name="rules[text][inputsize]"]').val()||'';
                rules.profile = $('select[name="rules[text][profile]"]').val()||'';
                rules.defaultvalue = $('input[name="rules[text][defaultvalue]"]').val()||'';
                data.rules = JSON.stringify(rules);
            }else if(data.type == "radio"){
                rules.choices = $("textarea[name='rules[radio][choices]']").val()||'';
                data.rules = JSON.stringify(rules);
            }else if(data.type == "checkbox"){
                rules.choices =$("textarea[name='rules[checkbox][choices]']").val()||'';
                data.rules = JSON.stringify(rules);
            }else if(data.type == "textarea"){
                rules.maxlength = $('input[name="rules[textarea][maxlength]"]').val()||'';
                rules.colsize = $('input[name="rules[textarea][colsize]"]').val()||'';
                rules.rowsize = $('input[name="rules[textarea][rowsize]"]').val()||'';
                rules.defaultvalue = $('input[name="rules[textarea][defaultvalue]"]').val()||'';
                data.rules = JSON.stringify(rules);
            }else if(data.type == "select"){
                rules.choices =$("textarea[name='rules[select][choices]']").val()||'';
                rules.inputsize = $('input[name="rules[select][inputsize]"]').val()||'';
                data.rules = JSON.stringify(rules);
            }else if(data.type == "calendar"){
                rules.inputsize = $('input[name="rules[calendar][inputsize]"]').val()||'';
                data.rules = JSON.stringify(rules);
            }else if(data.type == "range"){
                rules.maxnum = $('input[name="rules[range][maxnum]').val()||'';
                rules.minnum = $('input[name="rules[range][minnum]"]').val()||'';
                rules.inputsize = $('input[name="rules[range][inputsize]"]').val()||'';
                rules.searchtxt = $('input[name="rules[range][searchtxt]"]').val()||'';
                data.rules = JSON.stringify(rules);
            }else if(data.type =="image"){
                rules.maxwidth = $('input[name="rules[image][maxwidth]').val()||'';
                rules.maxheight = $('input[name="rules[image][maxheight]"]').val()||'';
                rules.inputsize = $('input[name="rules[image][inputsize]"]').val()||'';
                data.rules = JSON.stringify(rules);
            }

            console.log(data);
            $.ajax({
                url:"/admin/type/edittype",
                data:data,
                type:"post",
                success:function (res) {
                    if (res.errno==0) {
                        if (res.data.url) {

                            toastr.success(res.data.name + ' 页面即将自动跳转~');
                        }else{
                            toastr.success(res.data.name);
                        }
                        setTimeout(function(){
                            if (res.data.url) {
                                location.href=res.data.url;
                            }else{
                                location.reload();
                            }
                        },1500);
                    }
                }
            })
            return false;
        })

    })
</script>
{% endblock%}